package com.dwj.auto.comment.common.enums;

import com.dwj.auto.comment.common.wechat.handler.NuSubscribeHandler;
import com.dwj.auto.comment.common.wechat.handler.SubscribeHandler;
import com.dwj.auto.comment.common.wechat.handler.WxMessageHandler;

/**
 * @ClassName WxEventEnum
 * @Description 微信事件消息类型
 * @Author dwjian
 * @Date 2020/12/26 18:45
 */
public enum WxEventEnum {
    SUBSCRIBE("subscribe", "订阅通知", SubscribeHandler.class),
    UNSUBSCRIBE("unsubscribe", "取消订阅通知", NuSubscribeHandler.class);

    private String event;
    private String desc;
    private Class<? extends WxMessageHandler> handler;

    WxEventEnum(String event, String desc, Class<? extends WxMessageHandler> handler) {
        this.event = event;
        this.desc = desc;
        this.handler = handler;
    }

    public String getEvent() {
        return event;
    }

    public void setEvent(String event) {
        this.event = event;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public Class<? extends WxMessageHandler> getHandler() {
        return handler;
    }

    public void setHandler(Class<? extends WxMessageHandler> handler) {
        this.handler = handler;
    }

    public static WxEventEnum getByEvent(String event){
        for (WxEventEnum value : WxEventEnum.values()) {
            if(value.event.equals(event)){
                return value;
            }
        }
        return null;
    }
}
